﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Collections.Generic;

using CE.Global;
using CE.Database;

public partial class SiteUserHome : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        String selectedCulture = CE.Global.General.SetCulture();
        base.InitializeCulture();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null)
        {
            Response.Redirect("~/SiteUserSecureLogin.aspx");
        }

        if (Session[General.UserRole] != null && Session[General.UserRole].ToString() == "201")
        {
            Response.Redirect("~/carinsurance/PendingApplication.aspx");
        }

        LoadPageLink();
        CheckProviderUserType();

        if (!Page.IsPostBack)
        {
            DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
            lblLastLogin.Text = Resources.General.LastLoginDateTime + " : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "";
            DateTime time = CE.Global.General.GetUTCDateTime();
            lblTodayDate.Text += "Dashboard (" + time.ToString("dddd MMMM dd, yyyy") + ")";
            lblTodayDate.Font.Bold = true;

            CE.Global.General.ClearAllSession(this.Page, "all");

            CE.User.AccountStatusDB _accountStatusDB = new CE.User.AccountStatusDB();
            int _pwdStatus = _accountStatusDB.GetLastPasswordChagedStatus(Convert.ToInt64(Session[CE.Global.General.UserId].ToString()));
            if (_pwdStatus == 1)
            {
                Response.Redirect("~/User/ChangePassword.aspx");
            }

            //if (Session[General.IsRenewalAgent] != null && Session[General.IsRenewalAgent].ToString() == "1")
            //{
            //    liRenewalQuote.Visible = true;
            //}
            GetSalesGropChallenge();
        }
    }

    private string GetCarDetailCount(int intCallType)
    {
        string _retValue = "0";
        try
        {
            //[sprocCXCRMGetCarDetailCount]
            MyDatabase _db = new MyDatabase();
            string _spName = "sprocCXCRMGetCarDetailCount";
            SortedList _paraList = new SortedList();
            _paraList.Add("@CallType", intCallType);
            _paraList.Add("@LangOption", lblLangOption.Text);
            _paraList.Add("@AgentID", Convert.ToInt64(Session[CE.Global.General.UserId].ToString()));
            object _objRetCount = _db.ExecuteScalarSP(_spName, _paraList);
            if (_objRetCount != null)
            {
                _retValue = _objRetCount.ToString();
            }
        }
        catch (Exception Ex)
        {
            _retValue = "N/A";
        }
        return _retValue;
    }

    private void LoadPageLink()
    {
    }

    private void CheckProviderUserType()
    {
    }

    private string GetPendingCallBackCount()
    {
        string _retValue = "0";
        try
        {
            if (Session[CE.Global.General.UserId] != null)
            {
                MyDatabase _db = new MyDatabase();
                string _spName = "sprocCXCRMGetPendingCallBackCount";
                SortedList _paraList = new SortedList();
                _paraList.Add("@AgentId", Session[CE.Global.General.UserId].ToString());
                object _objRetCount = _db.ExecuteScalarSP(_spName, _paraList);
                if (_objRetCount != null)
                {
                    _retValue = _objRetCount.ToString();
                }
            }
        }
        catch (Exception Ex)
        {

        }
        return _retValue;
    }

    private void GetSalesGropChallenge()
    {
        try
        {
            #region Variable Declaration
            string _spName = "";
            Int32 _RankBy = 0;

            string _month = General.GetUTCDateTime().ToString("MMM");
            float _Target = 0.0f;
            float _Collection = 0.0f;
            float _Balance = 0.0f;
            Int16 _Rank = 0;
            float _targetper = 0.0f;
            float _salesper = 0.0f;
            Int32 _TotalWorkingDays = 0;
            Int32 _RemainWorkingDays = 0;
            Int32 _PastWorkingDays = 0;
            float _DailyTarget = 0.0f;
            float _TodayTarget = 0.0f;
            float _TodayCollection = 0.0f;

            int targetpercent = 0;
            string targetpercentdisplay = targetpercent.ToString() + "%";
            string targetcolor = "";
            int salepercent = 0;
            string salepercentdisplay = salepercent.ToString() + "%";
            string salecolor = "";

            Label lblChallengeIndividualAmount = (Label)Master.FindControl("lblChallengeIndividualAmount");
            Label lblChallengeBalanceTarget = (Label)Master.FindControl("lblChallengeBalanceTarget");
            Label lblChallengeRanking = (Label)Master.FindControl("lblChallengeRanking");
            #endregion

            MyDatabase _db = new MyDatabase();
            DataSet _dsAmount = new DataSet();

            if (Session[General.UserRole] != null && Session[General.UserRole].ToString() == "100")
            {
                Int64 intLoginUserId = 0;
                if (Session[General.UserId] != null)
                {
                    if (!Int64.TryParse(Session[General.UserId].ToString(), out intLoginUserId))
                    {
                        intLoginUserId = 0;
                    }
                }
                _spName = "sprocCXCRMAgentSalesRankSelectedItemList";
                SortedList _paraList = new SortedList();
                _paraList.Add("@LoginAgentId", intLoginUserId);
                //_paraList.Add("@LoginAgentId", "59141");
                _dsAmount = _db.GetDataSet(_spName, _paraList);

                #region Datatable Values
                DataTable _dtAgentSales = new DataTable();
                if (_dsAmount != null && _dsAmount.Tables.Count > 0)
                {
                    if (_dsAmount.Tables[0].Rows.Count > 0)
                    {
                        _RankBy = _dsAmount.Tables[0].Rows.Count;
                    }
                    if (_dsAmount.Tables.Count > 3 && _dsAmount.Tables[3].Rows.Count > 0)
                    {
                        _dtAgentSales = _dsAmount.Tables[0];
                    }
                }
                //if (Session[General.IsRenewalAgent] != null && Session[General.IsRenewalAgent].ToString() == "1")
                //{
                //    if (_dsAmount != null && _dsAmount.Tables.Count > 0)
                //    {
                //        if (_dsAmount.Tables.Count > 1 && _dsAmount.Tables[1].Rows.Count > 0)
                //        {
                //            _dtAgentSales = _dsAmount.Tables[1];
                //            _RankBy = _dsAmount.Tables[1].Rows.Count;
                //        }
                //    }
                //}
                //else
                //{
                //    if (_dsAmount != null && _dsAmount.Tables.Count > 0)
                //    {
                //        if (_dsAmount.Tables.Count > 0 && _dsAmount.Tables[0].Rows.Count > 0)
                //        {
                //            _dtAgentSales = _dsAmount.Tables[0];
                //            _RankBy = _dsAmount.Tables[0].Rows.Count;
                //        }
                //    }
                //}
                #endregion

                #region Collection & Ranking
                if (_dsAmount != null && _dsAmount.Tables.Count > 3 && _dsAmount.Tables[3].Rows.Count > 0)
                {
                    foreach (DataRow row in _dsAmount.Tables[3].Rows)
                    {
                        if (row["NameofMonth"].ToString().ToUpper() == _month.ToUpper())
                        {
                            _Target = Convert.ToSingle(row["TargetAmount"].ToString());
                        }
                    }
                }
                //if (_dsAmount != null && _dsAmount.Tables.Count > 2 && _dsAmount.Tables[2].Rows.Count > 0)
                //{
                //    foreach (DataRow row in _dsAmount.Tables[2].Rows)
                //    {
                //        foreach (DataColumn dc in _dsAmount.Tables[2].Columns)
                //        {
                //            string MonthCol = dc.ColumnName;
                //            if (MonthCol == _month)
                //            {
                //                _Target = Convert.ToSingle(row[dc].ToString());
                //            }
                //        }
                //    }
                //}
                if (_dsAmount != null && _dsAmount.Tables.Count > 1 && _dsAmount.Tables[1].Rows.Count > 0)
                {
                    _Collection = Convert.ToSingle(_dsAmount.Tables[1].Rows[0]["IndividualAmount"].ToString());
                    _Rank = Convert.ToInt16(_dsAmount.Tables[1].Rows[0]["AgentRank"].ToString());
                    _TotalWorkingDays = Convert.ToInt32(_dsAmount.Tables[1].Rows[0]["TotalWorkingDays"].ToString());
                    _RemainWorkingDays = Convert.ToInt32(_dsAmount.Tables[1].Rows[0]["RemainWorkingDays"].ToString());
                    _PastWorkingDays = _TotalWorkingDays - _RemainWorkingDays;
                }
                //if (Session[General.IsRenewalAgent] != null && Session[General.IsRenewalAgent].ToString() == "1")
                //{
                //    if (_dsAmount != null && _dsAmount.Tables.Count > 4 && _dsAmount.Tables[4].Rows.Count > 0)
                //    {
                //        _Collection = Convert.ToSingle(_dsAmount.Tables[4].Rows[0]["IndividualAmount"].ToString());
                //        _Rank = Convert.ToInt16(_dsAmount.Tables[4].Rows[0]["AgentRank"].ToString());
                //        _TotalWorkingDays = Convert.ToInt32(_dsAmount.Tables[4].Rows[0]["TotalWorkingDays"].ToString());
                //        _RemainWorkingDays = Convert.ToInt32(_dsAmount.Tables[4].Rows[0]["RemainWorkingDays"].ToString());
                //        _PastWorkingDays = _TotalWorkingDays - _RemainWorkingDays;
                //    }
                //}
                //else
                //{
                //    if (_dsAmount != null && _dsAmount.Tables.Count > 3 && _dsAmount.Tables[3].Rows.Count > 0)
                //    {
                //        _Collection = Convert.ToSingle(_dsAmount.Tables[3].Rows[0]["IndividualAmount"].ToString());
                //        _Rank = Convert.ToInt16(_dsAmount.Tables[3].Rows[0]["AgentRank"].ToString());
                //        _TotalWorkingDays = Convert.ToInt32(_dsAmount.Tables[3].Rows[0]["TotalWorkingDays"].ToString());
                //        _RemainWorkingDays = Convert.ToInt32(_dsAmount.Tables[3].Rows[0]["RemainWorkingDays"].ToString());
                //        _PastWorkingDays = _TotalWorkingDays - _RemainWorkingDays;
                //    }
                //}
                if (_dsAmount != null && _dsAmount.Tables.Count > 2 && _dsAmount.Tables[2].Rows.Count > 0)
                {
                    if (!float.TryParse(_dsAmount.Tables[2].Rows[0]["TodayCollection"].ToString(), out _TodayCollection))
                    {
                        _TodayCollection = 0.0f;
                    }
                }
                //if (_dsAmount != null && _dsAmount.Tables.Count > 5 && _dsAmount.Tables[5].Rows.Count > 0)
                //{
                //    if (!float.TryParse(_dsAmount.Tables[5].Rows[0]["TodayCollection"].ToString(), out _TodayCollection))
                //    {
                //        _TodayCollection = 0.0f;
                //    }
                //}

                if (_Collection > 0)
                {
                    _Balance = Convert.ToSingle(_Target - _Collection);
                }

                lblChallengeIndividualAmount.Text = Math.Floor(_Collection).ToString("#,000.00");
                lblChallengeBalanceTarget.Text = Math.Ceiling(_Balance).ToString("#,000.00");
                lblChallengeRanking.Text = _Rank.ToString() + "/" + _RankBy.ToString();

                _DailyTarget = _Target / _TotalWorkingDays;
                _TodayTarget = _DailyTarget;
                if (_Target > 0 && _Collection > 0)
                {
                    _targetper = (_Collection / _Target) * 100;
                    _TodayTarget = (_Target - _Collection) / _RemainWorkingDays;
                }

                if (_TodayTarget > 0 && _TodayCollection > 0)
                {
                    _salesper = (_TodayCollection / _TodayTarget) * 100;
                }

                #region Sales & Target - Values
                targetpercent = Convert.ToInt32(_targetper);
                targetpercentdisplay = targetpercent.ToString() + "%";
                targetcolor = "";
                salepercent = Convert.ToInt32(_salesper);
                salepercentdisplay = salepercent.ToString() + "%";
                salecolor = "";

                //Target
                if (targetpercent <= 25)
                {
                    targetcolor = "#ff2c2c";
                }
                else if (targetpercent > 25 && targetpercent <= 50)
                {
                    targetcolor = "#ff9212";
                }
                else if (targetpercent > 50 && targetpercent <= 75)
                {
                    targetcolor = "#ffe012";
                }
                else if (targetpercent > 75)
                {
                    targetcolor = "#71C73E";
                }

                //Sales
                if (salepercent <= 25)
                {
                    salecolor = "#ff2c2c";
                }
                else if (salepercent > 25 && salepercent <= 50)
                {
                    salecolor = "#ff9212";
                }
                else if (salepercent > 50 && salepercent <= 75)
                {
                    salecolor = "#ffe012";
                }
                else if (salepercent > 75)
                {
                    salecolor = "#71C73E";
                }
                divTarget.Attributes.Add("data-text", targetpercentdisplay);
                divTarget.Attributes.Add("data-percent", targetpercent.ToString());
                divTarget.Attributes.Add("data-fgcolor", targetcolor);
                divSales.Attributes.Add("data-text", salepercentdisplay);
                divSales.Attributes.Add("data-percent", salepercent.ToString());
                divSales.Attributes.Add("data-fgcolor", salecolor);
                #endregion

                #endregion
            }
            else if (Session[General.UserRole] != null && Session[General.UserRole].ToString() != "100")
            {
                _spName = "sprocCXCRMAgentSalesTargetSelectedItemList";
                SortedList _paraList = new SortedList();
                _paraList.Add("@LoginType", "2");
                _dsAmount = _db.GetDataSet(_spName, _paraList);

                #region Datatable Values
                DataTable _dtAgentSales = new DataTable();
                if (_dsAmount != null && _dsAmount.Tables.Count > 2)
                {
                    if (_dsAmount.Tables[2].Rows.Count > 0)
                    {
                        _dtAgentSales = _dsAmount.Tables[2];
                        _RankBy = _dsAmount.Tables[2].Rows.Count;
                    }
                }
                #endregion

                #region Collection & Ranking
                if (_dsAmount != null && _dsAmount.Tables.Count > 3 && _dsAmount.Tables[3].Rows.Count > 0)
                {
                    foreach (DataRow row in _dsAmount.Tables[3].Rows)
                    {
                        foreach (DataColumn dc in _dsAmount.Tables[3].Columns)
                        {
                            string MonthCol = dc.ColumnName;
                            if (MonthCol == _month)
                            {
                                _Target = Convert.ToSingle(row[dc].ToString());
                            }
                        }
                    }
                }

                if (_dsAmount != null && _dsAmount.Tables.Count > 4 && _dsAmount.Tables[4].Rows.Count > 0)
                {
                    _Collection = Convert.ToSingle(_dsAmount.Tables[4].Rows[0]["IndividualAmount"].ToString());
                    _Rank = Convert.ToInt16(_dsAmount.Tables[4].Rows[0]["AgentRank"].ToString());
                    _TotalWorkingDays = Convert.ToInt32(_dsAmount.Tables[4].Rows[0]["TotalWorkingDays"].ToString());
                    _RemainWorkingDays = Convert.ToInt32(_dsAmount.Tables[4].Rows[0]["RemainWorkingDays"].ToString());
                    _PastWorkingDays = _TotalWorkingDays - _RemainWorkingDays;
                }


                if (_dsAmount != null && _dsAmount.Tables.Count > 5 && _dsAmount.Tables[5].Rows.Count > 0)
                {
                    if (!float.TryParse(_dsAmount.Tables[5].Rows[0]["TodayCollection"].ToString(), out _TodayCollection))
                    {
                        _TodayCollection = 0.0f;
                    }
                }

                if (_Collection > 0)
                {
                    _Balance = Convert.ToSingle(_Target - _Collection);
                }

                lblChallengeIndividualAmount.Text = Math.Floor(_Collection).ToString("#,000.00");
                lblChallengeBalanceTarget.Text = Math.Ceiling(_Balance).ToString("#,000.00");
                lblChallengeRanking.Text = "";

                _DailyTarget = _Target / _TotalWorkingDays;
                _TodayTarget = _DailyTarget;
                if (_Target > 0 && _Collection > 0)
                {
                    _targetper = (_Collection / _Target) * 100;
                    _TodayTarget = (_Target - _Collection) / _RemainWorkingDays;
                }

                if (_TodayTarget > 0 && _TodayCollection > 0)
                {
                    _salesper = (_TodayCollection / _TodayTarget) * 100;
                }

                #region Sales & Target - Values
                targetpercent = Convert.ToInt32(_targetper);
                targetpercentdisplay = targetpercent.ToString() + "%";
                targetcolor = "";
                salepercent = Convert.ToInt32(_salesper);
                salepercentdisplay = salepercent.ToString() + "%";
                salecolor = "";

                //Target
                if (targetpercent <= 25)
                {
                    targetcolor = "#ff2c2c";
                }
                else if (targetpercent > 25 && targetpercent <= 50)
                {
                    targetcolor = "#ff9212";
                }
                else if (targetpercent > 50 && targetpercent <= 75)
                {
                    targetcolor = "#ffe012";
                }
                else if (targetpercent > 75)
                {
                    targetcolor = "#71C73E";
                }

                //Sales
                if (salepercent <= 25)
                {
                    salecolor = "#ff2c2c";
                }
                else if (salepercent > 25 && salepercent <= 50)
                {
                    salecolor = "#ff9212";
                }
                else if (salepercent > 50 && salepercent <= 75)
                {
                    salecolor = "#ffe012";
                }
                else if (salepercent > 75)
                {
                    salecolor = "#71C73E";
                }
                divTarget.Attributes.Add("data-text", targetpercentdisplay);
                divTarget.Attributes.Add("data-percent", targetpercent.ToString());
                divTarget.Attributes.Add("data-fgcolor", targetcolor);
                divSales.Attributes.Add("data-text", salepercentdisplay);
                divSales.Attributes.Add("data-percent", salepercent.ToString());
                divSales.Attributes.Add("data-fgcolor", salecolor);
                #endregion

                #endregion
            }

        }
        catch (Exception ex)
        {
        }
        finally
        {

        }
    }

    #region Not Using

    //private void GetSalesGropChallengeOld()
    //{
    //    StringBuilder strScript = new StringBuilder();
    //    try
    //    {
    //        Int32 _RankBy = 0;
    //        MyDatabase _db = new MyDatabase("GGR_DBConnectionString_TEST");
    //        string _spName = "sprocCXCRMAgentSalesRankSelectedItemList";
    //        DataSet _dsAmount = new DataSet();
    //        if (Session[General.UserRole] != null)
    //        //if (Session[General.UserRole] != null && Session[General.UserRole].ToString() == "100")
    //        {
    //            SortedList _paraList = new SortedList();
    //            _paraList.Add("@LoginAgentId", "59141");
    //            //_paraList.Add("@LoginAgentId", Session[CE.Global.General.UserId].ToString());
    //            _dsAmount = _db.GetDataSet(_spName, _paraList);
    //        }
    //        else
    //        {
    //            _dsAmount = _db.GetDataSet(_spName);
    //        }

    //        #region Chart Values
    //        DataTable _dtAgentSales = new DataTable();
    //        if (Session[General.IsRenewalAgent] != null && Session[General.IsRenewalAgent].ToString() == "1")
    //        {
    //            if (_dsAmount != null && _dsAmount.Tables.Count > 0)
    //            {
    //                if (_dsAmount.Tables.Count > 1 && _dsAmount.Tables[1].Rows.Count > 0)
    //                {
    //                    _dtAgentSales = _dsAmount.Tables[1];
    //                    _RankBy = _dsAmount.Tables[1].Rows.Count;
    //                }
    //            }
    //        }
    //        else
    //        {
    //            if (_dsAmount != null && _dsAmount.Tables.Count > 0)
    //            {
    //                if (_dsAmount.Tables.Count > 0 && _dsAmount.Tables[0].Rows.Count > 0)
    //                {
    //                    _dtAgentSales = _dsAmount.Tables[0];
    //                    _RankBy = _dsAmount.Tables[0].Rows.Count;
    //                }
    //            }
    //        }
    //        #endregion

    //        #region Collection & Ranking

    //        string _month = General.GetUTCDateTime().ToString("MMM");
    //        float _Target = 0.0f;
    //        float _Collection = 0.0f;
    //        float _Balance = 0.0f;
    //        Int16 _Rank = 0;
    //        float _targetper = 0.0f;
    //        float _salesper = 0.0f;
    //        Int32 _TotalWorkingDays = 0;
    //        Int32 _RemainWorkingDays = 0;
    //        Int32 _PastWorkingDays = 0;
    //        float _DailyTarget = 0.0f;
    //        float _TodayTarget = 0.0f;
    //        float _TodayCollection = 0.0f;

    //        if (_dsAmount != null && _dsAmount.Tables.Count > 2 && _dsAmount.Tables[2].Rows.Count > 0)
    //        {
    //            foreach (DataRow row in _dsAmount.Tables[2].Rows)
    //            {
    //                foreach (DataColumn dc in _dsAmount.Tables[2].Columns)
    //                {
    //                    string MonthCol = dc.ColumnName;
    //                    if (MonthCol == _month)
    //                    {
    //                        _Target = Convert.ToSingle(row[dc].ToString());
    //                    }
    //                }
    //            }
    //        }
    //        if (Session[General.IsRenewalAgent] != null && Session[General.IsRenewalAgent].ToString() == "1")
    //        {
    //            if (_dsAmount != null && _dsAmount.Tables.Count > 4 && _dsAmount.Tables[4].Rows.Count > 0)
    //            {
    //                _Collection = Convert.ToSingle(_dsAmount.Tables[4].Rows[0]["IndividualAmount"].ToString());
    //                _Rank = Convert.ToInt16(_dsAmount.Tables[4].Rows[0]["AgentRank"].ToString());
    //                _TotalWorkingDays = Convert.ToInt32(_dsAmount.Tables[4].Rows[0]["TotalWorkingDays"].ToString());
    //                _RemainWorkingDays = Convert.ToInt32(_dsAmount.Tables[4].Rows[0]["RemainWorkingDays"].ToString());
    //                _PastWorkingDays = _TotalWorkingDays - _RemainWorkingDays;
    //            }
    //        }
    //        else
    //        {
    //            if (_dsAmount != null && _dsAmount.Tables.Count > 3 && _dsAmount.Tables[3].Rows.Count > 0)
    //            {
    //                _Collection = Convert.ToSingle(_dsAmount.Tables[3].Rows[0]["IndividualAmount"].ToString());
    //                _Rank = Convert.ToInt16(_dsAmount.Tables[3].Rows[0]["AgentRank"].ToString());
    //                _TotalWorkingDays = Convert.ToInt32(_dsAmount.Tables[3].Rows[0]["TotalWorkingDays"].ToString());
    //                _RemainWorkingDays = Convert.ToInt32(_dsAmount.Tables[3].Rows[0]["RemainWorkingDays"].ToString());
    //                _PastWorkingDays = _TotalWorkingDays - _RemainWorkingDays;
    //            }
    //        }
    //        if (_dsAmount != null && _dsAmount.Tables.Count > 5 && _dsAmount.Tables[5].Rows.Count > 0)
    //        {
    //            if (!float.TryParse(_dsAmount.Tables[5].Rows[0]["TodayCollection"].ToString(), out _TodayCollection))
    //            {
    //                _TodayCollection = 0.0f;
    //            }
    //        }

    //        if (_Collection > 0)
    //        {
    //            _Balance = Convert.ToSingle(_Target - _Collection);
    //        }
    //        Label lblChallengeIndividualAmount = (Label)Master.FindControl("lblChallengeIndividualAmount");
    //        Label lblChallengeBalanceTarget = (Label)Master.FindControl("lblChallengeBalanceTarget");
    //        Label lblChallengeRanking = (Label)Master.FindControl("lblChallengeRanking");

    //        lblChallengeIndividualAmount.Text = Math.Floor(_Collection).ToString("#,000.00");
    //        lblChallengeBalanceTarget.Text = Math.Ceiling(_Balance).ToString("#,000.00");
    //        lblChallengeRanking.Text = _Rank.ToString() + "/" + _RankBy.ToString();

    //        _DailyTarget = _Target / _TotalWorkingDays;
    //        _TodayTarget = _DailyTarget;
    //        if (_Target > 0 && _Collection > 0)
    //        {
    //            _targetper = (_Collection / _Target) * 100;
    //            _TodayTarget = (_Target - _Collection) / _RemainWorkingDays;
    //        }

    //        if (_TodayTarget > 0 && _TodayCollection > 0)
    //        {
    //            _salesper = (_TodayCollection / _TodayTarget) * 100;
    //        }

    //        #region Sales & Target - Values
    //        int targetpercent = Convert.ToInt32(_targetper);
    //        string targetpercentdisplay = targetpercent.ToString() + "%";
    //        string targetcolor = "";
    //        int salepercent = Convert.ToInt32(_salesper);
    //        string salepercentdisplay = salepercent.ToString() + "%";
    //        string salecolor = "";

    //        //Target
    //        if (targetpercent <= 25)
    //        {
    //            targetcolor = "#ff2c2c";
    //        }
    //        else if (targetpercent > 25 && targetpercent <= 50)
    //        {
    //            targetcolor = "#ff9212";
    //        }
    //        else if (targetpercent > 50 && targetpercent <= 75)
    //        {
    //            targetcolor = "#ffe012";
    //        }
    //        else if (targetpercent > 75)
    //        {
    //            targetcolor = "#71C73E";
    //        }

    //        //Sales
    //        if (salepercent <= 25)
    //        {
    //            salecolor = "#ff2c2c";
    //        }
    //        else if (salepercent > 25 && salepercent <= 50)
    //        {
    //            salecolor = "#ff9212";
    //        }
    //        else if (salepercent > 50 && salepercent <= 75)
    //        {
    //            salecolor = "#ffe012";
    //        }
    //        else if (salepercent > 75)
    //        {
    //            salecolor = "#71C73E";
    //        }
    //        divTarget.Attributes.Add("data-text", targetpercentdisplay);
    //        divTarget.Attributes.Add("data-percent", targetpercent.ToString());
    //        divTarget.Attributes.Add("data-fgcolor", targetcolor);
    //        divSales.Attributes.Add("data-text", salepercentdisplay);
    //        divSales.Attributes.Add("data-percent", salepercent.ToString());
    //        divSales.Attributes.Add("data-fgcolor", salecolor);
    //        #endregion

    //        #endregion
    //    }
    //    catch (Exception ex)
    //    {
    //    }
    //    finally
    //    {

    //    }
    //}

    #endregion

}
